fp = open('Walden(1).txt', 'r', encoding='utf-8')
fp.seek(0)
wordslist1 = []
word = ()
text = fp.read()
text.lower()
for i in text:
    if i.isalpha():
        i.lower()
        word = word + i.lower()
    else:
        wordslist1.append(word)
        word = ''

wordslist2 = set(wordslist1)
wordslist2.remove('')
wordtimes = {}
for i in wordslist2:
    times = wordslist1.count(i)
    wordtimes[i] = times
print(wordtimes)

